import http from "../request";
const apibase = "/api/CalExcuteScript";

//获取计算脚本信息
var getCalExcuteScripts = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/GetCalExcuteScripts`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};

//批量新增计算脚本
var addCalExcuteScripts = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/AddCalExcuteScripts`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};

//批量修改计算脚本
var updateCalExcuteScripts = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/UpdateCalExcuteScripts`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};

//删除计算脚本
var deleteCalExcuteScript = function (data) {
  return new Promise((resolve, reject) => {
    http
      .post(apibase + `/DeleteCalExcuteScript`, data)
      .then((res) => {
        resolve(res);
      })
      .catch((error) => {
        reject(error);
      });
  });
};

export {
  getCalExcuteScripts,
  addCalExcuteScripts,
  updateCalExcuteScripts,
  deleteCalExcuteScript,
};
